package com.yiyang.controller;


import com.yiyang.pojo.Building;
import com.yiyang.pojo.BuildingRoom;
import com.yiyang.pojo.vo.PageResult;
import com.yiyang.pojo.vo.Result;
import com.yiyang.service.BuildingRoomService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/buildRoom")
@Tag(name = "BuildingRoomController",description = "楼宇-房间信息")
public class BuildingRoomController {
    @Autowired
    private BuildingRoomService buildingRoomService;
    @GetMapping("/{id}")
    public Result<BuildingRoom> getBuildingRoomById(@PathVariable("id") Integer id){
        return buildingRoomService.getBuildingRoomById(id);
    }
    @GetMapping
    public Result<PageResult<List<BuildingRoom>>> getAllBuildingRoom(
            @RequestParam(name = "currentPage",defaultValue = "1") Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "5") Integer pageSize,
            @RequestParam(name = "type",defaultValue = "") String type,
            @RequestParam(name = "description",defaultValue = "") String description
    ){
        return buildingRoomService.getAllBuildingRoom(currentPage,pageSize,type,description);
    }

    @PutMapping
    public Result<Void> addBuildingRoom(@RequestBody BuildingRoom buildingRoom){
        return buildingRoomService.addBuildingRoom(buildingRoom);
    }

    @PostMapping
    public Result<Void> updateBuildingRoom(@RequestBody BuildingRoom buildingRoom){
        return buildingRoomService.updateBuildingRoom(buildingRoom);
    }

    @DeleteMapping("/{id}")
    public Result<Void> deleteBuildingRoom(@PathVariable("id") Integer id){
        return buildingRoomService.deleteBuildingRoom(id);
    }
}
